package com.shop2cn.iapi.agentproducts.testcase;

import java.util.Arrays;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.agentproducts.parameter.AddAgentProductBean;
import com.shop2cn.iapi.agentproducts.parameter.SaveSelectionConditionBean;
import com.shop2cn.iapi.agentproducts.parameter.SelectionFilterBean;
import com.shop2cn.iapi.agentproducts.service.SelectionFilterCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AddAgentProductCallService;
/**
*选货中心条件筛选器Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SelectionFilter{
	private static SelectionFilterBean selectionfilterBean;
	private static SelectionFilterCall selectionfilterCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("选货中心条件筛选器Test");
	}

	@Before
	public void caseUp() {
		selectionfilterBean=new SelectionFilterBean();
		selectionfilterCall=new SelectionFilterCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(selectionfilterCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private int MchId=501163178;
	private int AgentId = 501163179;
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SelectionFilter_001() {
		Logger.start(true,"正确数据，成功");
		try {
			AddAgentProductBean addAgentProductBean = AddAgentProductCallService.initAddAgentProduct(MchId, "", true);
			String productId = AddAgentProductCallService.AddAgentProduct(addAgentProductBean);
			
			SaveSelectionConditionBean initSaveSelectionCondition = AddAgentProductCallService.InitSaveSelectionCondition(MchId, AgentId, 1);
			initSaveSelectionCondition.setBrandIdList(Arrays.asList(addAgentProductBean.getBrandId()));
			AddAgentProductCallService.SaveSelectionCondition(initSaveSelectionCondition);
			
			selectionfilterBean.setUserId(MchId);
			selectionfilterCall.setData(selectionfilterBean);
			selectionfilterCall.callService();
			Logger.verifyEquals("200", selectionfilterCall.getString("code"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}